﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using WCFServiceModel;
using Microsoft.WindowsAzure.MobileServices;

namespace WCFServiceModel.Model
{
    public class User
    {
        private string _id;
        [DataMember]
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }
       
        private int _age;
        [DataMember]
        public int Age
        {
            get { return _age; }
            set { _age = value; }
        }
        private string _email;
        [DataMember]
        public string Email
        {
            get { return _email; }
            set { _email = value; }
        }
        private double _longitude;
        [DataMember]
        public double Longitude
        {
            get { return _longitude; }
            set { _longitude = value; }
        }
        private double _latitude;
        [DataMember]
        public double Latitude
        {
            get { return _latitude; }
            set { _latitude = value; }
        }

        private IMobileServiceTable<User> userTable = ServiceManager.getCurrentContext().GetTable<User>();
        
        public User(int age, string email, double longitude, double latitude)
        {
            //_id = Guid.NewGuid().ToString();
            Age = age;
            Email = email;
            Longitude = longitude;
            Latitude = latitude;
            Insertuser(this);
        }


        private async void Insertuser(User u )
        {
            await userTable.InsertAsync(u);
           // items.Add(u);
        }
    }
}
